const express = require('express');
const handle = require('../router_handle/gedan_handle');
const app = express.Router();
const multer = require('multer');
const path = require('path');
const storage = multer.diskStorage({
	destination: function (req, file, cb) {
		cb(null, path.join(__dirname, '../uploads/gedan'));
	},
	filename: function (req, file, cb) {
		cb(null, 'gedan' + new Date().valueOf() + path.extname(file.originalname));
	}
})
const upload = multer({
	storage
})

// 新增gedantag(post)
// /gedan/addTag
// name create_time
app.post('/addTag', handle.addTag);
// 修改gedantag(post)
// /gedan/editTag
// id name(new)
app.post('/editTag', handle.editTag);
// 删除gedantag(get)
// /gedan/deleteTag
// id
app.get('/deleteTag', handle.deleteTag);
// 查看gedantag(get)
// /gedan/getTag
app.get('/getTag', handle.getTag);
// 通过id获取gedantag(get)
// /gedan/getTagById
// id
app.get('/getTagById', handle.getTagById);

// 添加gedan
// /gedan/add
// userid title pic musicid introduction gedantagid
app.post('/add', upload.single('pic'), handle.addGedan);
// 删除gedan
// /gedan/delete
// id
app.get('/delete', handle.deleteGedan);
// 获取gedan
// /gedan/get
app.get('/get', handle.getGedan);
// 修改gedan
// /gedan/edit
// id title pic musicid introduction gedantagid
app.post('/edit', upload.single('pic'), handle.editGedan);
// 通过gedantagid获取gedan
// /gedan/getGedanByGedanTagId
// gedantagid
app.get('/getGedanByGedanTagId', handle.getGedanByGedanTagId);
// 通过id获取gedan
// /gedan/getGedanById
// id
app.get('/getGedanById', handle.getGedanById);
// 通过userid获取歌单
// /gedan/getGedanByUserId
// userid
app.get('/getGedanByUserId', handle.getGedanByUserId);


module.exports = app